package com.yc.cloud.admin.controller;

import com.yc.cloud.admin.dto.request.HwCameraSnapshotRecordCreateReqDTO;
import com.yc.cloud.admin.dto.request.HwCameraSnapshotRecordUpdateReqDTO;
import com.yc.cloud.admin.dto.request.HwCameraSnapshotRecordPageReqDto;
import com.yc.cloud.admin.service.HwCameraSnapshotRecordService;
import com.yc.cloud.admin.vo.HwCameraSnapshotRecordVo;
import com.yc.cloud.common.basic.api.ResponseResult;
import com.yc.cloud.common.orm.CommonPage;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;

/**
 * <p>
 * 摄像头抓图记录表 前端控制器
 * </p>
 *
 * @author kinggu
 * @since 2025-10-10
 */
@RestController
@Api(tags = "摄像头抓图记录")
@RequestMapping("/hw-camera-snapshot-records")
public class HwCameraSnapshotRecordController {

    @Resource
    private HwCameraSnapshotRecordService hwCameraSnapshotRecordService;

    // @ApiOperation("创建摄像头抓图记录表")
    // @PostMapping
    // public ResponseResult<HwCameraSnapshotRecordVo> create(@Validated @RequestBody HwCameraSnapshotRecordCreateReqDTO createReqDTO) {
    //     HwCameraSnapshotRecordVo newVo = hwCameraSnapshotRecordService.create(createReqDTO);
    //     if (newVo != null) {
    //         return ResponseResult.success(newVo);
    //     }
    //     return ResponseResult.failed("创建失败");
    // }

    // @ApiOperation("更新摄像头抓图记录表")
    // @PutMapping("/{id}")
    // public ResponseResult<HwCameraSnapshotRecordVo> update(@PathVariable("id") Long id, @Validated @RequestBody HwCameraSnapshotRecordUpdateReqDTO updateReqDTO) {
    //     updateReqDTO.setId(id);
    //     HwCameraSnapshotRecordVo updatedVo = hwCameraSnapshotRecordService.update(updateReqDTO);
    //     if (updatedVo != null) {
    //         return ResponseResult.success(updatedVo);
    //     }
    //     return ResponseResult.failed("更新失败");
    // }

    @ApiOperation("删除摄像头抓图记录")
    @DeleteMapping("/{id}")
    public ResponseResult<Boolean> delete(@PathVariable("id") Long id) {
        boolean success = hwCameraSnapshotRecordService.delete(id);
        if (success) {
            return ResponseResult.success(true);
        }
        return ResponseResult.failed("删除失败");
    }

    // @ApiOperation("获取摄像头抓图记录表详情")
    // @GetMapping("/{id}")
    // public ResponseResult<HwCameraSnapshotRecordVo> getById(@PathVariable("id") Long id) {
    //     return ResponseResult.success(hwCameraSnapshotRecordService.getVOById(id));
    // }

    @ApiOperation("分页查询摄像头抓图记录（支持摄像头ID和日期范围过滤）")
    @GetMapping
    public ResponseResult<CommonPage<HwCameraSnapshotRecordVo>> list(@Validated HwCameraSnapshotRecordPageReqDto pageReqDTO) {
        return ResponseResult.success(hwCameraSnapshotRecordService.list(pageReqDTO));
    }
}
 